package com.xuecheng.filesystem.controller;

import com.xuecheng.api.filesystem.FileSystemControllerApi;
import com.xuecheng.filesystem.service.FileSystemService;
import com.xuecheng.framework.domain.filesystem.response.UploadFileResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by Aniymx on 2018/12/27 16:00.
 */
@RestController
@RequestMapping("/filesystem")
public class FileSystemController implements FileSystemControllerApi {
    /**
     * @Description: 上传图片
     * @Param:
     * @return:
     * @Author: Mr.aniymx
     * @Date:
     */
    @Autowired
    private FileSystemService fileSystemService;

    @Override
    @PostMapping("/upload")
    public UploadFileResult upload(
            @RequestParam(value = "file") MultipartFile multipartFile,
            @RequestParam(value = "filetag",required = true) String fileTag,
            @RequestParam(value = "businesskey",required = false) String businesskey,
            @RequestParam(value = "metadata",required = false) String metadata) {
        return fileSystemService.upload(multipartFile, fileTag, businesskey, metadata);
    }


}
